<?php
namespace app\index\controller;
use app\index\logic\MistakeLogic;

/**
 * 知错就改api控制器
 * Created by PhpStorm.
 * User: tyll
 * Date: 2019/10/08
 * Time: 15:41
 */
class Mistake extends Base {

    public function __construct(){
        parent::__construct();
        $this->m_logic = new MistakeLogic();
    }

    /**
     * 获取知错能改
     * @return \think\response\Json
     */
    public function ajax_get_mistake(){
        $params = input();
        $r = $this->check_user_token($params);
        if($r['code'] != 1){
            return json($r);
        }

        $maps = $this->m_logic->get_search_mistake_maps();
        //$limit = ($params['page'] - 1) * $params['rows'];

        $list = model('mistake')->get_list($maps,'id,content,now_date','now_date desc');
        foreach($list as $k => $v){
            $list[$k]['now_date'] = date('m-d',strtotime($v['now_date']));
        }

        $data['list'] = $list;
        return json($this->m_logic->get_response(1,'OK',$data));
    }
}
